package cn.lingyangwl.agile.pay;

import cn.lingyangwl.agile.model.constants.SecurityCons;
import cn.lingyangwl.agile.pay.model.rqrs.pay.payorder.*;
import cn.lingyangwl.agile.pay.model.rqrs.pay.refund.RefundOrderQO;
import cn.lingyangwl.agile.pay.model.rqrs.pay.refund.RefundOrderRQ;
import cn.lingyangwl.agile.pay.model.rqrs.pay.refund.RefundOrderRS;
import cn.lingyangwl.framework.core.response.Resp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author shenguangyang
 */
@FeignClient(contextId = "remotePayService", value = "${lingyang.pay-client.base-url}")
public interface PayFeignClient {
    /**
     * 统一下单接口
     */
    @PostMapping(value = "/pay/unifiedOrder", headers = SecurityCons.HEADER_FROM_IN)
    ResponseEntity<Resp<UnifiedOrderRS>> unifiedOrder(@RequestBody @Validated UnifiedOrderRQ req);

    /**
     * 继续去支付
     */
    @PostMapping(value = "/pay/continuePay", headers = SecurityCons.HEADER_FROM_IN)
    ResponseEntity<Resp<UnifiedOrderRS>> continuePay(@RequestBody @Validated ContinuePayRQ req);

    /**
     * 退款
     */
    @PostMapping(value = "/pay/refund/refundOrder", headers = SecurityCons.HEADER_FROM_IN)
    ResponseEntity<Resp<RefundOrderRS>> refundOrder(@RequestBody @Validated RefundOrderRQ rq);

    /**
     * 获取订单
     */
    @PostMapping(value = "/pay/getOrder", headers = SecurityCons.HEADER_FROM_IN)
    ResponseEntity<Resp<PayOrderRS>> getOrder(@RequestBody @Validated PayOrderQO req);

    /**
     * 获取交易的数据
     */
    @GetMapping(value = "/pay/trade/getTradeData", headers = SecurityCons.HEADER_FROM_IN)
    ResponseEntity<Resp<TradeDataRS>> getTradeData(@SpringQueryMap @Validated TradeDataQO req);

    /**
     * 获取退款订单
     */
    @GetMapping(value = "/pay/refund/getRefundOrder", headers = SecurityCons.HEADER_FROM_IN)
    ResponseEntity<Resp<RefundOrderRS>> getRefundOrder(@SpringQueryMap @Validated RefundOrderQO req);

    @PostMapping(value = "/pay/closeOrder", headers = SecurityCons.HEADER_FROM_IN)
    ResponseEntity<Resp<ClosePayOrderRS>> closePayOrder(@RequestBody ClosePayOrderRQ rq);
}
